#pragma once

#include "Color.h"
#include "Shape.h"

class AbstractFactory
{
public:
    AbstractFactory()          = default;
    virtual ~AbstractFactory() = default;

public:
    virtual Color *getColor(std::string color) const = 0;
    virtual Shape *getShape(std::string shape) const = 0;
};

class ColorFactory : public AbstractFactory
{
public:
    Color *getColor(std::string color) const override
    {
        if (color.compare("RED") == 0) {
            return new Red();
        } else if (color.compare("GREEN") == 0) {
            return new Green();
        } else if (color.compare("BLUE") == 0) {
            return new Blue();
        }
        return nullptr;
    }
    Shape *getShape(std::string shape) const override
    {
        return nullptr;
    }
};

class ShapeFactory : public AbstractFactory
{
public:
    Color *getColor(std::string color) const override
    {
        return nullptr;
    }
    Shape *getShape(std::string shape) const override
    {
        if (shape.compare("RECTANGLE") == 0) {
            return new Rectangle();
        } else if (shape.compare("SQUARE") == 0) {
            return new Square();
        } else if (shape.compare("CIRCLE") == 0) {
            return new Circle();
        }
        return nullptr;
    }
};

class FactoryProducer
{
public:
    static AbstractFactory *getFactory(std::string choice)
    {
        if (choice.compare("SHAPE") == 0) {
            return new ShapeFactory();
        } else if (choice.compare("COLOR") == 0) {
            return new ColorFactory();
        }
        return nullptr;
    }
};